

<div class="bao">
    <div class="title_top_sup">Xem nhiều nhất</div>
    <ul id="mycarousel" class="jcarousel-skin-tango">
        <?php
         $urlbtnxem = 'http://chomoionline.com/icon/btnxem.PNG';
        //$produc = Yii::app()->cache->get('producct');
        //if ($produc === FALSE) {
     
            $criteria = new CDbCriteria();
            $criteria->condition = 'flag=1 AND `pr_enddate` >= CURDATE() ORDER BY RAND()';
            $criteria->limit = 30;
            $produc = Product::model()->findAll($criteria);
            
            //Yii::app()->cache->set('producct', $produc, 1500);
        //}  
        if (!empty($produc)) {
            foreach ($produc as $pr) {
                ?>
                <li>

                    <div class="boxsp">
                        <div class="sale">
                            <div class="txtdiscount">
                                <?php 
                                if ($pr->discount > 1000) {
                                        echo '<div style="padding-top: 5px;font-size: 16px;">Quà</div>';
                                    } elseif ($pr->discount > 999) {
                                        echo '<div style="padding-top: 5px;font-size: 16px;">Mới</div>';
                                    } else {
                                        echo $pr->discount . '<span>%</span>';
                                       
                                        }
                                ?>
                                
                                
                            </div>
                        </div>
                        <div class="boxspImg">
                            <?php
                            $getUrl = $pr->pr_url;
                            $tang = "_top";
                            if ($getUrl === "") {
                                $getUrl = $this->createUrl('/noi-dung') . '/' . $pr->prid . '/' . $pr->asia_name . '/';
                            } else {
                                $tang = "_blank";
                            }
                            ?>
                            <a href="<?php echo $getUrl; ?>" title="<?php echo $pr->pr_name; ?>" target="<?php echo $tang; ?>">
                                <img src="<?php echo Yii::app()->request->baseUrl . '/upload/product/avata/' . $pr->avatar ?>" width="190" height="205">
                            </a>
                        </div>
                        <div class="boxspTitle">
                            <a href="<?php echo $getUrl; ?>" title="<?php echo $pr->pr_name; ?>" target="<?php echo $tang; ?>">
                                <?php echo $pr->pr_name; ?>
                            </a>
                        </div>
                        <div class="boxspPrice">
                            <div class="txttimer">
                                <div class="product-date-<?php echo $pr->prid; ?>"></div>

                                <script>
                                    jQuery(document).ready(function() {

                                        jQuery(".product-date-<?php echo $pr->prid; ?>").countdown({
        <?php
        if (($pr->pr_enddate) == '') {
            $date = new DateTime("1/1/2013 0:0:0");
        } else {
            $dd =date('Y-m-d',strtotime($pr->pr_enddate));
            if($dd==date('Y-m-d')){
               
                $date = new DateTime(date('Y-m-d', strtotime($dd. ' + 2 day')));
               
            }elseif ($dd==date('Y-m-d', strtotime(date('Y-m-d'). ' + 1 day'))) {
                 $date = new DateTime(date('Y-m-d', strtotime($dd. ' + 1 day')));
            }
            else {
                $date = new DateTime($pr->pr_enddate);
            }
            
        }
        $d=$date->format('Y-m-d');
        ?>

                                            date: "<?php echo $d; ?>",
                                            render: function(data) {
                                                jQuery(this.el).html("Còn " + this.leadingZeros(data.days, 2) + " <span> ngày </span>");
                                            }
                                        });

                                    });

                                </script>
                            </div>
                            <div class="btnXem">

                                <a href="<?php echo $getUrl; ?>" title="<?php echo $pr->pr_name; ?> " target="<?php echo $tang; ?>"><img src="<?php echo $urlbtnxem; ?>"></a>
                            </div>
                        </div>
                    </div>

                </li>
                <?php
            }
        }
        ?>
    </ul>
</div>

